/*
 * Copyright © 2022
 * @Author: zhangxiang
 * @Date: 2022-11-22 09:50:44
 * @LastEditors: zhangxiang
 * @LastEditTime: 2023-07-26 14:10:08
 * @Description:
 *
 */

import request from '@/utils/request'

/**
 * @description: 获取虚拟机列表
 * @param {*} data: os/osVersion
 * @return {*}
 */
export function getVMListByOS(data) {
  return request({
    url: '/api/vm/query',
    method: 'post',
    data
  })
}

/**
 * @description: 获取虚拟机列表
 * @param {*} params
 * @return {*}
 */
export function getVMList(data) {
  return request({
    url: '/api/vm/list',
    method: 'post',
    data
  })
}

/**
 * @description: 同步虚拟机列表
 * @param {*} params
 * @return {*}
 */
export function syncVM(params) {
  return request({
    url: '/api/vm/sync',
    method: 'get',
    params
  })
}

/**
 * @description: 创建虚拟机
 * @param {*} params
 * @return {*}
 */
export function createVM(data) {
  return request({
    url: '/api/vm/create',
    method: 'post',
    data,
    timeout: 5 * 60000 // 5分钟超时
  })
}

/**
 * @description: 预估虚拟机费用
 * @param {*} params
 * @return {*}
 */
export function priceVM(data) {
  return request({
    url: '/api/vm/price',
    method: 'post',
    data
  })
}

/**
 * @description: 更新虚拟机
 * @param {*} params
 * @return {*}
 */
export function updateVM(data) {
  return request({
    url: '/api/vm/update',
    method: 'post',
    data
  })
}

/**
 * @description: 虚拟机详情
 * @param {*} params
 * @return {*}
 */
export function detailVm(data) {
  return request({
    url: '/api/vm/detail',
    method: 'post',
    data
  })
}

/**
 * @description: 虚拟机 创建快照
 * @param {*} params
 * @return {*}
 */
export function createSnapshotVM(data) {
  return request({
    url: '/api/vm/createSnapshot',
    method: 'post',
    data
  })
}

/**
 * @description: 删除虚拟机
 * @param {*} params
 * @return {*}
 */
export function deleteVM(data) {
  return request({
    url: '/api/vm/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 开机
 * @param {*} params
 * @return {*}
 */
export function startVM(data) {
  return request({
    url: '/api/vm/start',
    method: 'post',
    data,
    timeout: 5 * 60000 // 5分钟超时
  })
}

/**
 * @description: 关机
 * @param {*} params
 * @return {*}
 */
export function stopVM(data) {
  return request({
    url: '/api/vm/stop',
    method: 'post',
    data,
    timeout: 5 * 60000 // 5分钟超时
  })
}

/**
 * @description: 远程连接
 * @param {*} params
 * @return {*}
 */
export function vncRemoteVM(data) {
  return request({
    url: '/api/vm/vnc',
    method: 'post',
    data
  })
}

/**
 * @description: 获取专有网络VPC列表
 * @param {*} data
 * @return {*}
 */
export function getNetworkVPCList(data) {
  return request({
    url: '/api/vpc/list',
    method: 'post',
    data
  })
}

/**
 * @description: 查询vpc
 * @param {*} params
 * @return {*}
 */
export function queryVPC(data) {
  return request({
    url: '/api/vpc/query',
    method: 'post',
    data
  })
}

/**
 * @description: 创建专有网络VPC
 * @param {*} data
 * @return {*}
 */
export function createNetworkVPC(data) {
  return request({
    url: '/api/vpc/create',
    method: 'post',
    data
  })
}

/**
 * @description: 删除专有网络VPC
 * @param {*} data
 * @return {*}
 */
export function deleteNetworkVPC(data) {
  return request({
    url: '/api/vpc/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 获取私有云网络列表
 * @param {*} data
 * @return {*}
 */
export function getNetworkList(data) {
  return request({
    url: '/api/network/list',
    method: 'post',
    data
  })
}

/**
 * @description: 查询私有云网络
 * @param {*} params
 * @return {*}
 */
export function queryNetwork(data) {
  return request({
    url: '/api/network/query',
    method: 'post',
    data
  })
}

/**
 * @description: 创建私有云网络
 * @param {*} data
 * @return {*}
 */
export function createNetwork(data) {
  return request({
    url: '/api/network/create',
    method: 'post',
    data
  })
}

/**
 * @description: 删除私有云网络
 * @param {*} data
 * @return {*}
 */
export function deleteNetwork(data) {
  return request({
    url: '/api/network/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 获取子网列表
 * @param {*} data
 * @return {*}
 */
export function getSubnetList(data) {
  return request({
    url: '/api/subnet/list',
    method: 'post',
    data
  })
}

/**
 * @description: 查询子网
 * @param {*} params
 * @return {*}
 */
export function querySubnet(data) {
  return request({
    url: '/api/subnet/query',
    method: 'post',
    data
  })
}

/**
 * @description: 创建子网
 * @param {*} data
 * @return {*}
 */
export function createSubnet(data) {
  return request({
    url: '/api/subnet/create',
    method: 'post',
    data
  })
}

/**
 * @description: 删除子网
 * @param {*} data
 * @return {*}
 */
export function deleteSubnet(data) {
  return request({
    url: '/api/subnet/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 获取安全组列表
 * @param {*} data
 * @return {*}
 */
export function getNSGList(data) {
  return request({
    url: '/api/nsg/list',
    method: 'post',
    data
  })
}

/**
 * @description: 查询安全组
 * @param {*} params
 * @return {*}
 */
export function queryNsg(data) {
  return request({
    url: '/api/nsg/query',
    method: 'post',
    data
  })
}

/**
 * @description: 创建安全组
 * @param {*} data
 * @return {*}
 */
export function createNSG(data) {
  return request({
    url: '/api/nsg/create',
    method: 'post',
    data
  })
}

/**
 * @description: 删除安全组
 * @param {*} data
 * @return {*}
 */
export function deleteNSG(data) {
  return request({
    url: '/api/nsg/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 获取安全组规则
 * @param {*} data
 * @return {*}
 */
export function getNSGRuleList(data) {
  return request({
    url: '/api/nsg/rule/list',
    method: 'post',
    data
  })
}

/**
 * @description: 创建安全组规则
 * @param {*} data
 * @return {*}
 */
export function createNSGRule(data) {
  return request({
    url: '/api/nsg/rule/create',
    method: 'post',
    data
  })
}

/**
 * @description: 删除安全组规则
 * @param {*} data
 * @return {*}
 */
export function deleteNSGRule(data) {
  return request({
    url: '/api/nsg/rule/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 修改安全组规则
 * @param {*} data
 * @return {*}
 */
export function updateNSGRule(data) {
  return request({
    url: '/api/nsg/rule/update',
    method: 'post',
    data
  })
}

/**
 * @description: 同步区域
 * @param {*} params
 * @return {*}
 */
export function syncRegion(params) {
  return request({
    url: '/api/region/sync',
    method: 'get',
    params
  })
}

/**
 * @description: 获取区域列表
 * @param {*} data
 * @return {*}
 */
export function getRegionList(data) {
  return request({
    url: '/api/region/list',
    method: 'post',
    data
  })
}

/**
 * @description: 编辑区域
 * @param {*} data
 * @return {*}
 */
export function updateRegion(data) {
  return request({
    url: '/api/region/update',
    method: 'post',
    data
  })
}

/**
 * @description: 删除区域
 * @param {*} data
 * @return {*}
 */
export function deleteRegion(data) {
  return request({
    url: '/api/region/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 同步规格
 * @param {*} params
 * @return {*}
 */
export function syncInstanceType(params) {
  return request({
    url: '/api/instanceType/sync',
    method: 'get',
    params
  })
}

/**
 * @description: 获取规格列表
 * @param {*} data
 * @return {*}
 */
export function getInstanceTypeList(data) {
  return request({
    url: '/api/instanceType/list',
    method: 'post',
    data
  })
}

/**
 * @description: 查询规格
 * @param {*} params
 * @return {*}
 */
export function queryInstanceType(data) {
  return request({
    url: '/api/instanceType/query',
    method: 'post',
    data
  })
}

/**
 * @description: 创建规格
 * @param {*} data
 * @return {*}
 */
export function createInstanceType(data) {
  return request({
    url: '/api/instanceType/create',
    method: 'post',
    data
  })
}

/**
 * @description: 编辑规格
 * @param {*} data
 * @return {*}
 */
export function updateInstanceType(data) {
  return request({
    url: '/api/instanceType/update',
    method: 'post',
    data
  })
}

/**
 * @description: 删除规格
 * @param {*} data
 * @return {*}
 */
export function deleteInstanceType(data) {
  return request({
    url: '/api/instanceType/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 同步镜像
 * @param {*} params
 * @return {*}
 */
export function syncImage(params) {
  return request({
    url: '/api/image/sync',
    method: 'get',
    params
  })
}

/**
 * @description: 获取镜像列表
 * @param {*} data
 * @return {*}
 */
export function getImageList(data) {
  return request({
    url: '/api/image/list',
    method: 'post',
    data
  })
}

/**
 * @description: 查询镜像
 * @param {*} params
 * @return {*}
 */
export function queryImage(data) {
  return request({
    url: '/api/image/query',
    method: 'post',
    data
  })
}

/**
 * @description: 创建镜像
 * @param {*} data
 * @return {*}
 */
export function createImage(data) {
  return request({
    url: '/api/image/create',
    method: 'post',
    data,
    headers: {
      'content-type': 'multipart/form-data'
    },
    timeout: 60 * 60000 // 60分钟超时
  })
}

/**
 * @description: 编辑镜像
 * @param {*} data
 * @return {*}
 */
export function updateImage(data) {
  return request({
    url: '/api/image/update',
    method: 'post',
    data
  })
}

/**
 * @description: 删除镜像
 * @param {*} data
 * @return {*}
 */
export function deleteImage(data) {
  return request({
    url: '/api/image/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 查询私有云可用域
 * @param {*} data
 * @return {*}
 */
export function getPrivateZones(data) {
  return request({
    url: '/api/account/private/zones',
    method: 'post',
    data
  })
}

/**
 * @description: 获取浮动ip列表
 * @param {*} data
 * @return {*}
 */
export function getFloatIPList(data) {
  return request({
    url: '/api/fip/list',
    method: 'post',
    data
  })
}

/**
 * @description: 分配浮动ip
 * @param {*} data
 * @return {*}
 */
export function allocateFloatIP(data) {
  return request({
    url: '/api/fip/allocate',
    method: 'post',
    data
  })
}

/**
 * @description: 绑定浮动ip
 * @param {*} data
 * @return {*}
 */
export function associateFloatIP(data) {
  return request({
    url: '/api/fip/associate',
    method: 'post',
    data
  })
}

/**
 * @description: 解绑/批量解绑 浮动ip
 * @param {*} data
 * @return {*}
 */
export function disassociateFloatIP(data) {
  return request({
    url: '/api/fip/disassociate',
    method: 'post',
    data
  })
}

/**
 * @description: 释放/批量释放 浮动ip
 * @param {*} data
 * @return {*}
 */
export function deleteFloatIP(data) {
  return request({
    url: '/api/fip/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 编辑 浮动ip
 * @param {*} data
 * @return {*}
 */
export function updateFloatIP(data) {
  return request({
    url: '/api/fip/update',
    method: 'post',
    data
  })
}

/**
 * @description: 获取 浮动ip pools
 * @param {*} data
 * @return {*}
 */
export function getFloatIPPools(data) {
  return request({
    url: '/api/fip/pools',
    method: 'post',
    data
  })
}

/**
 * @description: 获取 浮动ip ports
 * @param {*} data
 * @return {*}
 */
export function getFloatIPPorts(data) {
  return request({
    url: '/api/fip/ports',
    method: 'post',
    data
  })
}

/**
 * @description: 获取弹性ip列表
 * @param {*} data
 * @return {*}
 */
export function getElasticIPList(data) {
  return request({
    url: '/api/eip/list',
    method: 'post',
    data
  })
}

/**
 * @description: 创建弹性ip
 * @param {*} data
 * @return {*}
 */
export function createElasticIP(data) {
  return request({
    url: '/api/eip/create',
    method: 'post',
    data
  })
}

/**
 * @description: 绑定弹性ip
 * @param {*} data
 * @return {*}
 */
export function associateElasticIP(data) {
  return request({
    url: '/api/eip/associate',
    method: 'post',
    data
  })
}

/**
 * @description: 绑定弹性ip-待绑定云主机
 * @param {*} data
 * @return {*}
 */
export function getAssociateElasticIPVMs(data) {
  return request({
    url: '/api/eip/associate/vm',
    method: 'post',
    data
  })
}

/**
 * @description: 解绑/批量解绑 弹性ip
 * @param {*} data
 * @return {*}
 */
export function unassociateElasticIP(data) {
  return request({
    url: '/api/eip/unassociate',
    method: 'post',
    data
  })
}

/**
 * @description: 释放/批量释放 弹性ip
 * @param {*} data
 * @return {*}
 */
export function releaseElasticIP(data) {
  return request({
    url: '/api/eip/release',
    method: 'post',
    data
  })
}

/**
 * @description: 编辑 弹性ip
 * @param {*} data
 * @return {*}
 */
export function updateElasticIP(data) {
  return request({
    url: '/api/eip/update',
    method: 'post',
    data
  })
}

/**
 * @description: 挂载云盘
 * @param {*} data
 * @return {*}
 */
export function attachStorageBlock(data) {
  return request({
    url: '/api/storage/block/attach',
    method: 'post',
    data
  })
}

/**
 * @description: 挂载云盘-主机列表
 * @param {*} data
 * @return {*}
 */
export function getAttachStorageBlockVms(data) {
  return request({
    url: '/api/storage/block/attach/vm',
    method: 'post',
    data
  })
}

/**
 * @description: 创建云盘
 * @param {*} data
 * @return {*}
 */
export function createStorageBlock(data) {
  return request({
    url: '/api/storage/block/create',
    method: 'post',
    data
  })
}

/**
 * @description: 删除云盘
 * @param {*} data
 * @return {*}
 */
export function deleteStorageBlock(data) {
  return request({
    url: '/api/storage/block/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 卸载云盘
 * @param {*} data
 * @return {*}
 */
export function detachStorageBlock(data) {
  return request({
    url: '/api/storage/block/detach',
    method: 'post',
    data
  })
}

/**
 * @description: 云盘列表
 * @param {*} data
 * @return {*}
 */
export function getStorageBlockList(data) {
  return request({
    url: '/api/storage/block/list',
    method: 'post',
    data
  })
}

/**
 * @description: 编辑云盘
 * @param {*} data
 * @return {*}
 */
export function updateStorageBlock(data) {
  return request({
    url: '/api/storage/block/update',
    method: 'post',
    data
  })
}

/**
 * @description: 云盘-卷来源
 * @param {*} data
 * @return {*}
 */
export function getBlockVolumeSource(data) {
  return request({
    url: '/api/storage/block/volumeSource',
    method: 'post',
    data
  })
}

/**
 * @description: 云盘-组
 * @param {*} data
 * @return {*}
 */
export function getBlockVolumeGoup(data) {
  return request({
    url: '/api/storage/block/volumeGoup',
    method: 'post',
    data
  })
}

/**
 * @description: 云盘-卷类型
 * @param {*} data
 * @return {*}
 */
export function getBlockVolumeType(data) {
  return request({
    url: '/api/storage/block/volumeType',
    method: 'post',
    data
  })
}

/**
 * @description: 路由列表
 * @param {*} data
 * @return {*}
 */
export function getRouterList(data) {
  return request({
    url: '/api/router/list',
    method: 'post',
    data
  })
}

/**
 * @description: 创建路由
 * @param {*} data
 * @return {*}
 */
export function createRouter(data) {
  return request({
    url: '/api/router/create',
    method: 'post',
    data
  })
}

/**
 * @description: 路由创建-获取网络
 * @param {*} data
 * @return {*}
 */
export function getRouterNetworks(data) {
  return request({
    url: '/api/router/networks',
    method: 'post',
    data
  })
}

/**
 * @description: 删除路由
 * @param {*} data
 * @return {*}
 */
export function deleteRouter(data) {
  return request({
    url: '/api/router/delete',
    method: 'post',
    data
  })
}
/**
 * @description: 路由接口列表
 * @param {*} data
 * @return {*}
 */
export function getRouterPortList(data) {
  return request({
    url: '/api/router/port/list',
    method: 'post',
    data
  })
}

/**
 * @description: 删除 路由接口
 * @param {*} data
 * @return {*}
 */
export function deleteRouterPort(data) {
  return request({
    url: '/api/router/port/delete',
    method: 'post',
    data
  })
}

/**
 * @description: 创建 路由接口
 * @param {*} data
 * @return {*}
 */
export function addRouterPort(data) {
  return request({
    url: '/api/router/port/add',
    method: 'post',
    data
  })
}

/**
 * @description: 路由接口 子网列表
 * @param {*} data
 * @return {*}
 */
export function getRouterPortSubnets(data) {
  return request({
    url: '/api/router/port/subnets',
    method: 'post',
    data
  })
}
